<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
use Jedrzej\Pimpable\PimpableTrait;

class PromoterLevel extends Model
{
    use HasFactory;
    use PimpableTrait;
    use SoftDeletes;

    /**
     * 默认排序
     */
    protected $defaultSortCriteria = ['id,desc'];

    /**
     * 可排序字段
     */
    protected $sortable = [
        'position',
        'level',
        'first_commission',
        'second_commission',
        'promoter_id'
    ];

    /**
     * 可搜索字段
     */
    protected $searchable = [
        'position',
        'level',
        'first_commission',
        'second_commission',
        'is_show',
        'promoter_id',
        'user_id'
    ];

    /**
     * 可批量赋值字段
     */
    protected $fillable = [
        'position',
        'level',
        'first_commission',
        'second_commission',
        'is_show',
        'image',
        'promoter_id',
        'user_id'
    ];

        /**
         * 用户的分销等级
         */
        public function Promoter(){
            return $this->belongsTo(User::class,'user_id','id');
        }
}
